package hui.zhang.web.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import hui.zhang.domain.system.Permission;
import hui.zhang.service.system.PermissionService;
import hui.zhang.utils.BaseAction;

/**
 * 权限管理
 * 
 * @author hui.zhang
 * @date 2017年12月30日 下午8:12:54
 */

@Controller
@ParentPackage("struts-default")
@Namespace("/")
@Scope("prototype")
@SuppressWarnings("all")
public class PermissionAction extends BaseAction<Permission> {

	@Autowired
	private PermissionService permissionService;

	@Action(value = "permission_list")
	public String list() {
		List<Permission> permissions = permissionService.findAll();
		toJsonAndResponse(permissions);
		return NONE;
	}

	@Action(value = "permission_save", results = {
			@Result(name = "success", type = "redirect", location = "/pages/system/permission.html") })
	public String save() {
		permissionService.save(model);
		return SUCCESS;
	}
}
